package chances.epg.ui.web;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import chances.epg.ui.config.EpgUIResolver;

public class EpgUIListener implements ServletContextListener{
	private EpgUIResolver epgUIResolver;
	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		epgUIResolver = null;
	}

	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		String name = arg0.getServletContext().getInitParameter(EpgUIResolver.PARAM_NAME);
		try {
			epgUIResolver = (EpgUIResolver) Class.forName(name).newInstance();
			arg0.getServletContext().setAttribute(epgUIResolver.NAME, epgUIResolver);
		} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
			e.printStackTrace();
		}
		
	}

}
